<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/FCKeditor.tld" prefix="fck" %>
<%@page import="java.util.*,model.*,util.*,control.*,java.text.*"%>
<%@ taglib uri="/WEB-INF/displaytag.tld" prefix="display"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>

            <%
           /*
           *验证权限
           *author 宋智洋
           *data 2011-11-26
           *update 胡瑾
           *data 2011-12-01
           *增加了userId
           */
			String flag = (String)session.getAttribute("flag");
			String userId = (String)session.getAttribute("userId");
			int studentId = Integer.parseInt(userId);
						
			if (flag != "student"|| flag==null )
			{
				%>
            <script language="javascript">
				     alert("您没有学生权限,请重新登录"); window.location.href="../../index.jsp";
				    </script>
            <%
				
			}else{
				Student student = new Student();
				StudentControl sc = new StudentControl();
				student = sc.GetStudent(studentId);
				out.print("<p>"+student.getStudentName()+"   欢迎您</p>");
			}
           %>
           
 
          <%
			request.setCharacterEncoding("utf-8");
			double cita= ParamUtil.getDouble(request,"cita",0.0);	
		/************************************************************************************/	
		/*
		*统计用时与成绩
		*author 胡瑾
		*data 2011-11-30
		*/
			String tmpString = ParamUtil.getString(request,"tmpString");
			String startDate = ParamUtil.getString(request,"startDate");
			String nowDate = ParamUtil.getString(request,"nowDate");
			int n=ParamUtil.getInt(request,"n");
			
			DateFormat df = new SimpleDateFormat("yyyy-MM-dd-HH:mm:ss"); 
			Date d1 = df.parse(startDate);
			Date d2 = df.parse(nowDate);
			long diff = (d2.getTime() - d1.getTime()) / 1000; //以防万一设置long 除以1000转换成秒
	
	
			String testString = Long.toString(diff);			
		/************************************************************************************/	
		/*
		*查询成绩
		*author 胡瑾
		*data 2011-11-27
		*update 2011-12-06 加入开始时间
		*update 2011-12-08加入题数
		*/
		
			Score score = new Score();
			ScoreControl sc = new ScoreControl();
			score.setStudentId(studentId);
			score.setScore(cita);
			//等星哥
			score.setTestTime(testString);
			score.setTestTime_start(startDate);
			score.setProblemNum(n);
			sc.insertScore(score);
			
		/************************************************************************************/
		/*
		*四舍五入
		*author hujin
		*2011-12-08
		*/
		double cita_show = Math.floor((cita + 0.05d)*10)/10;
		%>
          <link href="../../../css/btn.css" rel="stylesheet" type="text/css" />
<div> <p>您本次测验的能力估计值为：<%=cita_show%><br/>
            共回答题数为：<%=n %><br/>
            测试用时为：<%=testString %>秒 <br></p>
            <input type="button" value="再来一次" class="btn-blue" onClick="window.location.href='problem.jsp'">
           <a href="student_index.jsp">
            <BUTTON id="btn-login" class="btn-blue" type="submit">返回</BUTTON>
       		</a>
          </div>


</html>
